#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/times.h>

/**
  * @brief  Provides a tick value in millisecond.
  * @retval tick value
  */
int64_t Hal_GetTick(void)
{
    static int isGetPer = false;
    static unsigned long perSecondTick;
    if (!isGetPer) {
        perSecondTick = sysconf(_SC_CLK_TCK);
        isGetPer = true;
    }
    return (unsigned long)times(NULL)*1000L/perSecondTick;
}

bool Hal_IsTicksTimeout(int64_t hisTickTemp, int64_t timeoutMs)
{
    if ((int64_t)(Hal_GetTick() - hisTickTemp) >= timeoutMs)
    {
        return true;
    }
    else
    {
        return false;
    }
}

